package com.yanchangapp.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanchangapp.R;
import com.yanchangapp.commom.ApproveStatus;
import com.yanchangapp.model.bean.GoodsApproveBean;
import com.zxl.baselib.util.ui.ResHelper;
import java.util.List;

/**
 * Created by apple on 2019-08-26.
 * description:采购审批的adapter
 *
 * examineStatus = 1 已通过  /  = 2 已驳回
 */
public class GoodsApproveAdapter extends BaseQuickAdapter<GoodsApproveBean, BaseViewHolder> {

    public GoodsApproveAdapter(int layoutResId, @Nullable List<GoodsApproveBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsApproveBean item) {
        helper.setText(R.id.tvRecordName,item.getBuyer());
        helper.setText(R.id.tvRecordDept,item.getDepartment());
        TextView tvTag = helper.getView(R.id.tvTag);
        // 对时间进行设置...
        if (ApproveStatus.WAIT_SUBMIT.getStatus().equals(String.valueOf(item.getStatus()))){
            helper.setText(R.id.tvCreateTime, ResHelper.getString(R.string.apply_time,item.getCreateTime()));
            // 设置不可见
            tvTag.setVisibility(View.VISIBLE);
            tvTag.setText(item.getExamineStatusName());
            tvTag.setBackground(ResHelper.getDrawable(R.drawable.tag_order_submit));
        }else {
            helper.setText(R.id.tvCreateTime,ResHelper.getString(R.string.approve_time,item.getCreateTime()));
            tvTag.setVisibility(View.VISIBLE);
            // 设置可见
            tvTag.setText(item.getExamineStatusName());
            // 设置 通过/驳回...状态背景
            if (item.getExamineStatus() == 1){
                tvTag.setBackground(ResHelper.getDrawable(R.drawable.tag_order_pass));
            }else {
                tvTag.setBackground(ResHelper.getDrawable(R.drawable.tag_order_reject));
            }
        }
    }
}
